@section('title')
    我的积分 @parent
@show

@section('subcontent')

{{ HTML::style('css/list_scores.css')}}
<div id="mainUserInfo">

<div class="mod-main mod-comm lefta-box">
    <div class="mt">
		<h3 class="curr">我的积分</h3>
    </div>
    <div class="mc">
    		<div class="scores-use">
    			<p>可用积分： {{Auth::user()->score}}</p>
    			<p><a href="##" class="but01">积分抽奖</a><a href="##"  class="but02">积分兑换</a></p>
    		</div>
	        <div  class="scores-box">
	        	<div class="toptitle">积分明细</div>
				<div class="scorestitle">
					<span class="span">积分来源</span>
					<span class="span">积分变化</span>
					<span class="span">获取时间</span>
				</div>
				<ul class="scores">
				</ul>
			</div>
    </div>
</div>
</div>
<script type="text/javascript">
var url = '{{ Config::get('app.url') }}/center/score/list_scores';
$(".but01,.but02").click(function(){
	layer.msg("敬请期待")
});
$(document).ready(function(){
        $(".scores li").remove();
        var loading = '<li><div class="loading">加载中...</div></li>'; 
        $(".scores").append(loading);
          $.get(url, function(data){
              }, "json").error(function(data) {
                var status_code = $.parseJSON(data.responseText);
                layer.msg(status_code.message);
              }).success(function(data) {
                $(".loading").parent().remove();
                var record = "";
                var obj = data.data;
                if(obj != null && obj.length != 0){
                   for (var i = 0; i < obj.length; i++) {
                    record+='<li>'
                      record+='<span class="span">'+obj[i].title+'</span>'
                      record+='<span class="span">+'+obj[i].score+'</span>'
                      record+='<span class="span">'+obj[i].created_at+'</span>'
                    record+='</li>';
                  }
                }else {
                      record+='<li class="nodata">';
                        record+='暂无数据！';
                      record+='</li>';
                  }
                $(".scores").append(record);
                for(var j=0; j<obj.length; j++){
                  if (j%2 == 0) {
                  $(".scores li").eq(j).css("background-color","#f0f0f0");
                    }
                }
            });

        });
</script>
@show